package com.googlecode.imanager.client.util;

import java.io.Serializable;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class Dimension implements Serializable {

    private static final long serialVersionUID = 1L;

    private int width;    
    private int height;

    public Dimension() {
    }

    public Dimension(int width, int height) {
        this.width = width;
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }
    
    public void addSize(int width, int height) {
        this.width += width;
        this.height += height;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == this){
            return true;
        }
        if (obj instanceof Dimension){
            Dimension r = (Dimension) obj;
            return (r.width == width)
                && (r.height == height);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return width ^ (height << 16);
    }

    @Override
    public String toString() {
        return "Dimension[width=" + width + ", height=" + height + "]";
    }
    
}
